list(APPEND WebCore_INCLUDE_DIRECTORIES
    "${WEBCORE_DIR}/platform/cdroid"
    "${WEBCORE_DIR}/platform/cairo"
    "${WEBCORE_DIR}/platform/geoclue"
    "${WEBCORE_DIR}/platform/graphics/cairo"
    "${WEBCORE_DIR}/platform/graphics/cdroid"
    "${WEBCORE_DIR}/platform/graphics/freetype"
    "${WEBCORE_DIR}/platform/graphics/harfbuzz/"
    "${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
    "${WEBCORE_DIR}/platform/graphics/opengl"
    "${WEBCORE_DIR}/platform/graphics/opentype"
    "${WEBCORE_DIR}/platform/graphics/texmap/coordinated"
    "${WEBCORE_DIR}/platform/linux"
    "${WEBCORE_DIR}/platform/mediastream/gstreamer"
    "${WEBCORE_DIR}/platform/mock/mediasource"
    "${3RDPARTY_DIR}/libjpeg"
    "${3RDPARTY_DIR}/libpng"
    "${3RDPARTY_DIR}/libxml2/include"
    "${3RDPARTY_DIR}/libxslt/include"
    "${3RDPARTY_DIR}/sqlite"
    "${3RDPARTY_DIR}/zlib"
    "${CDROID_INCLUDE_DIRS}"
)

set(SOUP_SRCS
    platform/network/soup/AuthenticationChallengeSoup.cpp
    platform/network/soup/CertificateInfo.cpp
    platform/network/soup/CookieJarSoup.cpp
    platform/network/soup/CookieStorageSoup.cpp
    platform/network/soup/CredentialStorageSoup.cpp
    platform/network/soup/DNSSoup.cpp
    platform/network/soup/NetworkStorageSessionSoup.cpp
    platform/network/soup/ProxyServerSoup.cpp
    platform/network/soup/ResourceErrorSoup.cpp
    platform/network/soup/ResourceHandleSoup.cpp
    platform/network/soup/ResourceRequestSoup.cpp
    platform/network/soup/ResourceResponseSoup.cpp
    platform/network/soup/SocketStreamHandleSoup.cpp
    platform/network/soup/SoupNetworkSession.cpp
    platform/network/soup/SynchronousLoaderClientSoup.cpp
    platform/soup/SharedBufferSoup.cpp
    platform/soup/URLSoup.cpp
)

set(CURL_SRCS
    platform/network/curl/CertificateInfo.cpp
    platform/network/curl/CookieJarCurl.cpp
    platform/network/curl/CredentialStorageCurl.cpp
    platform/network/curl/CurlCacheEntry.cpp
    platform/network/curl/CurlCacheManager.cpp
    platform/network/curl/CurlDownload.cpp
    platform/network/curl/DNSCurl.cpp
    platform/network/curl/FormDataStreamCurl.cpp
    platform/network/curl/MultipartHandle.cpp
    platform/network/curl/ProxyServerCurl.cpp
    platform/network/curl/ResourceHandleCurl.cpp
    platform/network/curl/ResourceHandleManager.cpp
    platform/network/curl/SocketStreamHandleCurl.cpp
    platform/network/curl/SSLHandle.cpp
    platform/network/curl/SynchronousLoaderClientCurl.cpp
)
if (USE_SOUP)
    message("USE_SOUP")
    set(NETWORK_SOURCES ${SOUP_SRCS})
    set(NETWORK_LIBRARIES ${LIBSOUP_LIBRARIES})
    set(NETWORK_INCLUDE_DIRS  ${LIBSOUP_INCLUDE_DIRS} "${WEBCORE_DIR}/platform/network/soup" CACHE PATH "")
    list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/network/soup")
else()
    message("USE_CURL")
    set(NETWORK_SOURCES ${CURL_SRCS})
    set(NETWORK_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
    set(NETWORK_INCLUDE_DIRS  ${CURL_INCLUDE_DIRS} "${WEBCORE_DIR}/platform/network/curl" CACHE PATH "")
    list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/network/curl")
endif()

list(APPEND WebCore_SOURCES
    accessibility/atk/AXObjectCacheAtk.cpp
    accessibility/atk/AccessibilityObjectAtk.cpp
    accessibility/atk/WebKitAccessibleHyperlink.cpp
    accessibility/atk/WebKitAccessibleInterfaceAction.cpp
    accessibility/atk/WebKitAccessibleInterfaceComponent.cpp
    accessibility/atk/WebKitAccessibleInterfaceDocument.cpp
    accessibility/atk/WebKitAccessibleInterfaceEditableText.cpp
    accessibility/atk/WebKitAccessibleInterfaceHyperlinkImpl.cpp
    accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp
    accessibility/atk/WebKitAccessibleInterfaceImage.cpp
    accessibility/atk/WebKitAccessibleInterfaceSelection.cpp
    accessibility/atk/WebKitAccessibleInterfaceTable.cpp
    accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp
    accessibility/atk/WebKitAccessibleInterfaceText.cpp
    accessibility/atk/WebKitAccessibleInterfaceValue.cpp
    accessibility/atk/WebKitAccessibleUtil.cpp
    accessibility/atk/WebKitAccessibleWrapperAtk.cpp

    editing/SmartReplace.cpp

    editing/atk/FrameSelectionAtk.cpp 
    editing/cdroid/EditorCd.cpp

    html/shadow/MediaControlsApple.cpp

    loader/soup/CachedRawResourceSoup.cpp
    loader/soup/SubresourceLoaderSoup.cpp

    page/cdroid/DragControllerCd.cpp   
    page/cdroid/EventHandlerCd.cpp 

    #page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
    #page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
    #page/scrolling/coordinatedgraphics/ScrollingStateScrollingNodeCoordinatedGraphics.cpp

    platform/ContextMenuItemNone.cpp
    platform/ContextMenuNone.cpp
    platform/Cursor.cpp

    platform/cairo/WidgetBackingStoreCairo.cpp

    platform/ScrollAnimatorNone.cpp

    platform/cdroid/BatteryProviderCd.cpp
    platform/cdroid/CursorCd.cpp
    platform/cdroid/DragDataCd.cpp
    platform/cdroid/DragImageCd.cpp
    platform/cdroid/CdInspectorUtilities.cpp
    platform/cdroid/CdKeyboardUtilities.cpp
    platform/cdroid/CdScreenUtilities.cpp
    platform/cdroid/ErrorsCd.cpp
    platform/cdroid/EventLoopCd.cpp
    platform/cdroid/GamepadsCd.cpp
    platform/cdroid/LanguageCd.cpp
    platform/cdroid/LocalizedStringsCd.cpp
    platform/cdroid/LoggingCd.cpp
    platform/cdroid/MIMETypeRegistryCd.cpp
    platform/cdroid/PasteboardCd.cpp
    platform/cdroid/ContextMenuCd.cpp
    platform/cdroid/ContextMenuItemCd.cpp
    platform/cdroid/PlatformKeyboardEventCd.cpp
    platform/cdroid/PlatformMouseEventCd.cpp
    platform/cdroid/PlatformScreenCd.cpp
    platform/cdroid/PlatformWheelEventCd.cpp
    platform/cdroid/RenderThemeCd.cpp
    platform/cdroid/ScrollbarCd.cpp
    platform/cdroid/ScrollbarThemeCd.cpp
    platform/cdroid/SharedTimerCd.cpp
    platform/cdroid/SoundCd.cpp
    platform/cdroid/TemporaryLinkStubs.cpp
    platform/cdroid/WidgetCd.cpp
    platform/cdroid/MediaPlayerCD.cpp
    platform/cdroid/PlatformMouseEventCd.cpp
    platform/cdroid/PlatformKeyboardEventCd.cpp
    platform/cdroid/PlatformTouchPointCd.cpp
    platform/cdroid/PlatformTouchEventCd.cpp

    #platform/geoclue/GeolocationProviderGeoclue1.cpp
    #platform/geoclue/GeolocationProviderGeoclue2.cpp

    platform/graphics/WOFFFileFormat.cpp
    platform/graphics/ImageSource.cpp

    platform/graphics/cairo/BitmapImageCairo.cpp
    platform/graphics/cairo/CairoUtilities.cpp
    platform/graphics/cairo/FontCairo.cpp
    platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
    platform/graphics/cairo/GradientCairo.cpp
    platform/graphics/cairo/GraphicsContextCairo.cpp
    platform/graphics/cairo/ImageBufferCairo.cpp
    platform/graphics/cairo/ImageCairo.cpp
    platform/graphics/cairo/IntRectCairo.cpp
    platform/graphics/cairo/OwnPtrCairo.cpp
    platform/graphics/cairo/PathCairo.cpp
    platform/graphics/cairo/PatternCairo.cpp
    platform/graphics/cairo/PlatformContextCairo.cpp
    platform/graphics/cairo/PlatformPathCairo.cpp
    platform/graphics/cairo/RefPtrCairo.cpp
    platform/graphics/cairo/TransformationMatrixCairo.cpp
    
    platform/graphics/cdroid/CairoUtilitiesCd.cpp  
    platform/graphics/cdroid/IconCd.cpp      
    platform/graphics/cdroid/IntRectCd.cpp
    platform/graphics/cdroid/ImageCd.cpp
    platform/graphics/cdroid/IntPointCd.cpp

    platform/graphics/freetype/FontCacheFreeType.cpp
    platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
    platform/graphics/freetype/FontPlatformDataFreeType.cpp
    platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
    platform/graphics/freetype/SimpleFontDataFreeType.cpp
    platform/graphics/freetype/FontPlatformDataFreeType.cpp

    platform/graphics/harfbuzz/HarfBuzzFace.cpp
    platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
    platform/graphics/harfbuzz/HarfBuzzShaper.cpp

    #platform/graphics/opentype/OpenTypeVerticalData.cpp

    platform/graphics/texmap/coordinated/AreaAllocator.cpp
    platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
    #platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
    platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
    #platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
    platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
    platform/graphics/texmap/coordinated/CoordinatedSurface.cpp
    platform/graphics/texmap/coordinated/CoordinatedTile.cpp
    platform/graphics/texmap/coordinated/UpdateAtlas.cpp

    platform/image-decoders/cairo/ImageDecoderCairo.cpp
    platform/image-decoders/ImageDecoder.cpp
    platform/image-decoders/cairo/ImageDecoderCairo.cpp
    platform/image-decoders/gif/GIFImageDecoder.cpp
    platform/image-decoders/gif/GIFImageReader.cpp
    platform/image-decoders/ico/ICOImageDecoder.cpp
    platform/image-decoders/jpeg/JPEGImageDecoder.cpp
    platform/image-decoders/bmp/BMPImageDecoder.cpp
    platform/image-decoders/bmp/BMPImageReader.cpp
    platform/image-decoders/png/PNGImageDecoder.cpp
    platform/image-decoders/webp/WEBPImageDecoder.cpp

    platform/linux/GamepadDeviceLinux.cpp
    platform/linux/MemoryPressureHandlerLinux.cpp
    platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp


    platform/network/NetworkStorageSessionStub.cpp

    ${NETWORK_SOURCES}

    platform/posix/FileSystemPOSIX.cpp
    platform/cdroid/FileSystemCd.cpp
    platform/posix/SharedBufferPOSIX.cpp


    platform/text/icu/UTextProvider.cpp
    platform/text/icu/UTextProviderLatin1.cpp
    platform/text/icu/UTextProviderUTF16.cpp 

    platform/text/LocaleNone.cpp
    #platform/text/LocaleICU.cpp
    platform/text/cdroid/TextBreakIteratorInternalICUCd.cpp

    #rendering/RenderThemeWince.cpp
    platform/text/enchant/TextCheckerEnchant.cpp

    plugins/PluginPackageNone.cpp
    plugins/PluginViewNone.cpp
)

list(APPEND WebCore_USER_AGENT_STYLE_SHEETS
    ${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsApple.css
)

if (WTF_USE_TEXTURE_MAPPER)
    list(APPEND WebCore_SOURCES
        platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
    )
endif ()

set(WebCore_USER_AGENT_SCRIPTS
    ${WEBCORE_DIR}/English.lproj/mediaControlsLocalizedStrings.js
    ${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsApple.js
)

set(WebCore_USER_AGENT_SCRIPTS_DEPENDENCIES ${WEBCORE_DIR}/platform/efl/RenderThemeEfl.cpp)

list(APPEND WebCore_LIBRARIES
    ${ATK_LIBRARIES}
    ${CAIRO_LIBRARIES}
    ${ENCHANT_LIBRARIES}
    ${FONTCONFIG_LIBRARIES}
    ${FREETYPE2_LIBRARIES}
    #${GEOCLUE_LIBRARIES}
    #${GLIB_GIO_LIBRARIES}
    #${GLIB_GMODULE_LIBRARIES}
    #${GLIB_GOBJECT_LIBRARIES}
    #${GLIB_LIBRARIES}
    ${GUDEV_LIBRARIES}
    ${HARFBUZZ_LIBRARIES}
    ${GRAPHITE_LIBRARIES}
    ${NETWORK_LIBRARIES}
    ${ICU_LIBRARIES}
    ${ICU_I18N_LIBRARIES}
    ${JPEG_LIBRARIES}
    ${LIBSECRET_LIBRARIES}
    ${NETWORK_LIBRARIES}
    ${LIBXML2_LIBRARIES}
    ${LIBXSLT_LIBRARIES}
    ${PNG_LIBRARIES}
    ${SQLITE_LIBRARIES}
    ${WEBP_LIBRARIES}
    ${ZLIB_LIBRARIES}
    ${CDROID_LIBRARIES}
)

list(APPEND WebCore_INCLUDE_DIRECTORIES
    ${CAIRO_INCLUDE_DIRS}
    ${FREETYPE2_INCLUDE_DIRS}
    ${GEOCLUE_INCLUDE_DIRS}
    ${LIBXML2_INCLUDE_DIR}
    ${LIBXSLT_INCLUDE_DIR}
    ${SQLITE_INCLUDE_DIR}
    ${GLIB_INCLUDE_DIRS}
    ${ZLIB_INCLUDE_DIRS}
    ${NETWORK_INCLUDE_DIRS}
    ${HARFBUZZ_INCLUDE_DIRS}
    ${OPENSSL_INCLUDE_DIRS}
)
if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        "${WEBCORE_DIR}/platform/graphics/gstreamer"

	#${GSTREAMER_INCLUDE_DIRS}
	#${GSTREAMER_BASE_INCLUDE_DIRS}
	#${GSTREAMER_APP_INCLUDE_DIRS}
	#${GSTREAMER_PBUTILS_INCLUDE_DIRS}
    )

    list(APPEND WebCore_LIBRARIES
	#${GSTREAMER_APP_LIBRARIES}
	#${GSTREAMER_BASE_LIBRARIES}
	#${GSTREAMER_LIBRARIES}
	#${GSTREAMER_PBUTILS_LIBRARIES}
    )
    # Avoiding a GLib deprecation warning due to GStreamer API using deprecated classes.
    set_source_files_properties(platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp PROPERTIES COMPILE_DEFINITIONS "GLIB_DISABLE_DEPRECATION_WARNINGS=1")
endif ()

if (ENABLE_VIDEO AND NOT ENABLE_CDROID_VIDEO)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        ${GSTREAMER_TAG_INCLUDE_DIRS}
        ${GSTREAMER_VIDEO_INCLUDE_DIRS}
    )
    list(APPEND WebCore_LIBRARIES
        ${GSTREAMER_TAG_LIBRARIES}
        ${GSTREAMER_VIDEO_LIBRARIES}
    )
endif ()

if (WTF_USE_3D_GRAPHICS)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        "${WEBCORE_DIR}/platform/graphics/opengl"
        "${WEBCORE_DIR}/platform/graphics/surfaces"
        "${WEBCORE_DIR}/platform/graphics/surfaces/efl"
        "${WEBCORE_DIR}/platform/graphics/surfaces/glx"
        "${WEBCORE_DIR}/platform/graphics/texmap"
    )

    if (WTF_USE_EGL)
        list(APPEND WebCore_INCLUDE_DIRECTORIES
            ${EGL_INCLUDE_DIR}
            "${WEBCORE_DIR}/platform/graphics/surfaces/egl"
    )
    endif ()
    list(APPEND WebCore_SOURCES
        platform/graphics/cairo/DrawingBufferCairo.cpp

	platform/graphics/cdroid/CdGLContext.cpp
	platform/graphics/cdroid/CdGLSurface.cpp
	platform/graphics/cdroid/GraphicsContext3DCd.cpp
        platform/graphics/cdroid/GraphicsContext3DPrivate.cpp

        platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
        platform/graphics/opengl/GLPlatformContext.cpp
        platform/graphics/opengl/GLPlatformSurface.cpp
        platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
        platform/graphics/opengl/TemporaryOpenGLSetting.cpp

        platform/graphics/surfaces/GLTransportSurface.cpp
        platform/graphics/surfaces/GraphicsSurface.cpp

        #platform/graphics/surfaces/cdroid/GraphicsSurfaceCommon.cpp

        #platform/graphics/surfaces/glx/X11Helper.cpp

        platform/graphics/texmap/TextureMapperGL.cpp
        platform/graphics/texmap/TextureMapperShaderProgram.cpp
    )
    if (WTF_USE_EGL)
        list(APPEND WebCore_SOURCES
            platform/graphics/surfaces/egl/EGLConfigSelector.cpp
            platform/graphics/surfaces/egl/EGLContext.cpp
            platform/graphics/surfaces/egl/EGLHelper.cpp
            platform/graphics/surfaces/egl/EGLSurface.cpp
            platform/graphics/surfaces/egl/EGLXSurface.cpp
        )
    else ()
        list(APPEND WebCore_SOURCES
            platform/graphics/surfaces/glx/GLXContext.cpp
            platform/graphics/surfaces/glx/GLXSurface.cpp
        )
    endif ()

    if (WTF_USE_OPENGL_ES_2)
        list(APPEND WebCore_SOURCES
            platform/graphics/opengl/Extensions3DOpenGLES.cpp
            platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
        )
    else ()
        list(APPEND WebCore_SOURCES
            platform/graphics/OpenGLShims.cpp

            platform/graphics/opengl/Extensions3DOpenGL.cpp
            platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
        )
    endif ()

    if (WTF_USE_EGL)
        list(APPEND WebCore_LIBRARIES
            ${EGL_LIBRARY}
        )
    endif ()
endif ()

if (ENABLE_WEB_AUDIO)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        "${WEBCORE_DIR}/platform/audio/gstreamer"

        ${GSTREAMER_AUDIO_INCLUDE_DIRS}
        ${GSTREAMER_FFT_INCLUDE_DIRS}
    )
    list(APPEND WebCore_LIBRARIES
        ${GSTREAMER_AUDIO_LIBRARIES}
        ${GSTREAMER_FFT_LIBRARIES}
    )
    set(WEB_AUDIO_DIR ${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/webaudio/resources)
    file(GLOB WEB_AUDIO_DATA "${WEBCORE_DIR}/platform/audio/resources/*.wav")
    install(FILES ${WEB_AUDIO_DATA} DESTINATION ${WEB_AUDIO_DIR})
    add_definitions(-DUNINSTALLED_AUDIO_RESOURCES_DIR="${WEBCORE_DIR}/platform/audio/resources")
endif ()

if (ENABLE_SPELLCHECK)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        ${ENCHANT_INCLUDE_DIRS}
    )
    list(APPEND WebCore_LIBRARIES
        ${ENCHANT_LIBRARIES}
    )
endif ()

if (ENABLE_SPELLCHECK)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        ${ENCHANT_INCLUDE_DIRS}
    )
    list(APPEND WebCore_LIBRARIES
        ${ENCHANT_LIBRARIES}
    )
endif ()

if (ENABLE_ACCESSIBILITY)
    list(APPEND WebCore_INCLUDE_DIRECTORIES
        "${WEBCORE_DIR}/accessibility/atk"
        ${ATK_INCLUDE_DIRS}
    )
    list(APPEND WebCore_LIBRARIES
        ${ATK_LIBRARIES}
    )
endif ()

if (ENABLE_SPEECH_SYNTHESIS)
    list(APPEND WebCore_SOURCES
        platform/efl/PlatformSpeechSynthesizerEfl.cpp
        platform/efl/PlatformSpeechSynthesisProviderEfl.cpp
    )
endif ()
